fish_vi_key_bindings

set -Ux EDITOR "nvim"

set -l dir (status dirname)
set -l volta_home "$HOME/.volta"
set -l cargo_home "$HOME/.cargo"

# Add volta bin
if test -d $volta_home
  set -gx VOLTA_HOME $volta_home
  fish_add_path -p "$volta_home/bin"
end

# Add cargo bin
if test -d $cargo_home
  fish_add_path -p "$cargo_home/bin"
end

if status is-interactive
  alias tx="tmuxinator"

  fish_add_path -p "$HOME/.local/bin"

  # Initialize starship if exists
  if type -q starship
    starship init fish | source
  end

  # Initialize zoxide if exists
  if type -q zoxide
    zoxide init fish | source
  end

  # Initialize atuin if exists
  if type -q atuin
    set -gx ATUIN_NOBIND "true"
    atuin init fish | source
    bind \cr _atuin_search
    bind -M insert \cr _atuin_search
  end

  source $dir/plugins.fish
end

function venv -d "Activate python venv"
    source  .venv/bin/activate.fish
end

function cls --description 'Clear screen'
  command clear
end

function tx --description 'Run tmuxinator with fzf'
  set -l project (tmuxinator list | tail -1 | tr -s '[[:space:]]' '\n' | fzf --reverse --height 10% --cycle --header "Project: " --header-first)
  if test -n "$project"
    tmuxinator start $project
  end
end
